package com.ct.ecommerce.framework.core.response;


/**
 * @author changtong
 * @since 2021/5/19
 */
public final class ResponseBuilder {
    private ResponseBuilder() {}

    private static final String DEFAULT_MESSAGE = "操作成功！";

    public static BaseResponse buildSuccessResponse() {
        BaseResponse response = new BaseResponse();
        response.setSuccess(Boolean.TRUE);
        response.setMessage(DEFAULT_MESSAGE);
        return response;
    }

    public static BaseResponse buildSuccessResponse(Object obj) {
        BaseResponse response = new BaseResponse();
        response.setSuccess(Boolean.TRUE);
        response.setMessage(DEFAULT_MESSAGE);
        response.setResult(obj);
        return response;
    }

    public static BaseResponse buildSuccessResponse(Object obj, String message) {
        BaseResponse response = new BaseResponse();
        response.setSuccess(Boolean.TRUE);
        response.setResult(obj);
        response.setMessage(message);
        return response;
    }

    public static BaseResponse buildFailedResponse(String errorMessage) {
        BaseResponse response = new BaseResponse();
        response.setSuccess(Boolean.FALSE);
        response.setMessage(errorMessage);
        return response;
    }



}
